﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ReportAccountRoomInfo.aspx.cs" Inherits="CMS.ReportAccountRoomInfo" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2009.1.311.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div style="font-size: 26px; font-weight: bold; text-align: center;">QUẢN TRỊ TÀI KHOẢN - PHÒNG CHƠI</div>
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
        <table>
            <tr>
                <td>Từ ngày :
        <telerik:RadDatePicker ID="txtFromDate" runat="server" Skin="Default" DateInput-DateFormat="MM/dd/yyyy"
            DateInput-DisplayDateFormat="dd/MM/yyyy">
        </telerik:RadDatePicker>
                </td>
                <td>Đến ngày :
        <telerik:RadDatePicker ID="txtToDate" runat="server" Skin="Default" DateInput-DateFormat="MM/dd/yyyy"
            DateInput-DisplayDateFormat="dd/MM/yyyy">
        </telerik:RadDatePicker>
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="Xem" OnClick="Button1_Click" /></td>
            </tr>
        </table>

        <br />
        <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" AllowPaging="True" PageSize="20" GridLines="None" Width="100%" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging">
            <Columns>
                <asp:BoundField HeaderText="Lượt" DataField="BetLogID"></asp:BoundField>
                <asp:BoundField HeaderText="Số Line cược" DataField="CountLineBet" DataFormatString="{0:n0}"></asp:BoundField>
                <asp:BoundField HeaderText="Số Line thắng" DataField="CountLineWin" DataFormatString="{0:n0}"></asp:BoundField>
                <asp:BoundField HeaderText="Tổng thắng" DataField="WinMoney" DataFormatString="{0:n0}"></asp:BoundField>
                <asp:BoundField HeaderText="Ngày" DataField="TimeWin"></asp:BoundField>
                <asp:TemplateField HeaderText="Chi tiết">
                    <ItemTemplate>
                        <a href="javascript:;" onclick="javascript:showPopup(<%# Eval("BetLogID") %>)">Chi tiết</a>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        </asp:GridView>
    </telerik:RadAjaxPanel>
    <script type="text/javascript">

        function showPopup(id) {
            CloseDialog();
            var width = 900;
            var height = 600;
            var content = '';
            var html = '';
            content += '<div style="overflow-y: scroll; height:560px; padding:10px; ">';
            content += '<div style="width:500px; margin:0 auto; font-size:24px; text-align:center; padding:10px;"><b>Kết quả quay</b></div>';
            $.ajax({
                type: "GET",
                url: "/ChartApi.ashx?t=detailsBetLog&id=" + id,
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    console.log(data);
                    var roomid = data.roomid;

                    var arrValues = data.result.substr(0, data.result.length - 1).split(',');
                    content += '<div style="width:610px; height:372px; margin:0 auto; background:url(Images/play' + roomid + '.png) no-repeat;">';
                    content += '<div style="width:565px; height:315px; margin:0px auto; padding-top: 56px;">';
                    $.each(arrValues, function (intIndex, objValue) {
                        content += '<img src="' + getImgById(objValue, roomid) + '" style="padding:3px 9px;" />';
                    });
                    content += '</div>';
                    content += '</div>';
                    if (data.jsondetail != "[]") {
                        var resp = JSON.stringify(eval("(" + data.jsondetail + ")"));
                        content += '<ul class="bang_line">';
                        $.each($.parseJSON(resp), function (i, item) {
                            content += '<li><a href="javascript:" class="line' + item.line + '" alt="1"></a> trúng x' + item.amount + ': ' + formatMoney(item.win) + ' Sao</li>';
                        });
                        content += '</ul>';
                    } else {
                        content += '<div style="text-align:center;"><b>Không có line nào trúng</b></div>';
                    }
                    content += '</div>';
                    html =
                        '<div id="Popup_Container" style="width:' + width + 'px; border:1px solid Gray; background:#fff;">' +
                        '<div  id="popup_nd">' +
                        '<div onclick="CloseDialog();" style="position:absolute;right:15px; cursor:pointer;width:45px;height:50px;float:right;top:15px;">Đóng</div>' +
                        '<div id="temPopup">' + content +
                        '</div></div></div>' +
                        '<div onclick="CloseDialog();"  id="overlay" class="overlay" style="width:100%; height:100%; position:fixed; top:0px;"></div>' +
                        '';

                    $('BODY').append(html);

                    $('#popup_nd').css('width', width);
                    $('#popup_nd').css('height', height);
                    var leftOffset = ($(window).width() - width) / 2;
                    var topOffset = ($(window).height() - height) / 2 + $(window).scrollTop();
                    $('#Popup_Container').css('left', leftOffset + "px");
                    $('#Popup_Container').css('z-index', 1300);
                    $('#Popup_Container').css("top", topOffset + "px");
                    $('#Popup_Container').css('position', 'absolute');
                    $('#overlay').css('height', $(document).height());
                    $('#overlay').show();
                }
            });
        }

        function CloseDialog() {
            $('#Popup_Container').remove();
            $('#overlay').remove();
            $('.popup').remove();
            $('.overlay').remove();
        }

        function getImgById(id, roomid) {
            var pathFolder = "Images/Room1";
            switch (roomid) {
                case 1:;
                    pathFolder = "Images/Room1";
                    break;
                case 2:
                    pathFolder = "Images/Room2";
                    break;
                case 3:
                    pathFolder = "Images/Room3";
                    break;
            }

            return pathFolder + "/" + id + ".png";
        }
        function formatMoney(argValue) {
            var _comma = (1 / 2 + '').charAt(1);
            var _digit = ',';
            if (_comma == ',') {
                _digit = ',';
            }

            var _sSign = "";
            if (argValue < 0) {
                _sSign = "-";
                argValue = -argValue;
            }
            var _sTemp = "" + argValue;
            var _index = _sTemp.indexOf(_comma);
            var _digitExt = "";
            if (_index != -1) {
                _digitExt = _sTemp.substring(_index + 1);
                _sTemp = _sTemp.substring(0, _index);
            }
            var _sReturn = "";
            while (_sTemp.length > 3) {
                _sReturn = _digit + _sTemp.substring(_sTemp.length - 3) + _sReturn;
                _sTemp = _sTemp.substring(0, _sTemp.length - 3);
            }
            _sReturn = _sSign + _sTemp + _sReturn;
            if (_digitExt.length > 0) {
                _sReturn += _comma + _digitExt;
            }
            return _sReturn;
        };

    </script>
</asp:Content>
